// JavaScript Document
//www.eparinay.com

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var emID = "Invalid E-mail ID!";
		if (str.indexOf(at)==-1){
		   alert(emID);
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(emID);
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(emID);
		    return false;
		}

		 //Commented to accept multiple emails.
		 //if (str.indexOf(at,(lat+1))!=-1){
		 //   alert("Invalid E-mail ID")
		 //   return false
		 //}

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(emID);
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(emID);
		    return false;
		 }

		 if (str.indexOf(" ")!=-1){
		    alert(emID);
		    return false;
		 }

 		 return true
	}




function chkRegisterForm(){
	with(document.reg){
		var peu = "Please enter your ";
		//if(doValidate())
		//{
			//alert("Please select atleast one user type!");
			//return false;
		//}
	
		if(name.value == "" ){
			alert(peu+"First Name!");
			name.focus();
			return false;
		}
		if(surname.value == "" ){
			alert(peu+"Last Name!");
			surname.focus();
			return false;
		}
		if(father_name.value == "" ){
			alert(peu+"Father Name!");
			father_name.focus();
			return false;
		}
		if(father_info.value.length < 30){
			alert("Father information should be atleast 30 characters!");
			father_info.focus();
			return false;
		}
		if(address.value.length < 20){
			alert("Address should be atleast 20 characters!");
			address.focus();
			return false;
		}
		if(Date_of_Birth.value == ""){
			alert(peu+"birth date!");
			Date_of_Birth.focus();
			return false;
		}
		if(email.value == ""){
			alert(peu+"email address!");
			email.focus();
			return false;
		}
		if(!echeck(email.value)){
			email.focus();
			return false;
		}
		if(password1.value == ""){
			alert(peu+"password!");
			password1.focus();
			return false;
		}
		if(password1.value.length < 6){
			alert("Password length should be atleast 6 characters!");
			password1.focus();
			return false;
		}
		if(tel.value == ""){
			alert(peu+"Telephone!");
			tel.focus();
			return false;
		}
		if(income.value == ""){
			alert(peu+"Income!");
			income.focus();
			return false;
		}
		if(marital_status.value == ""){
			alert("Please Select your Marital Status!");
			marital_status.focus();
			return false;
		}
		if(aboutfamily.value.length < 50){
			alert("About Family should be atleast 50 characters!");
			aboutfamily.focus();
			return false;
		}
		if(expectation.value.length < 50){
			alert("Expectation length should be atleast 50 characters!");
			expectation.focus();
			return false;
		}
		
		
		//if(Address.value.length < 6 )
		//{
			//alert("Address length should be minimum 6 characters!");
			//Address.focus();
			//return false;
		//}
		
		
		
			//if(friend_email.value == "" )
			//{
			//	alert(peu+"friend's email address!");
			//	friend_email.focus();
			//	return false;
			//}
			//if(!echeck(friend_email.value))
			//{
			//	friend_email.focus();
			//	return false;
			//}
	
		return true;
	}
}

<!--
// Validation for non empty fields and correct input values
function chklogin(){
	with(document.login){
		var cl = "Please enter your ";
		if(username.value == "" ){
			alert(cl+"email address!");
			username.focus();
			return false;
		}
		if(!echeck(username.value)){
			username.focus();
			return false;
		}
		if(password.value==""){
			alert(cl+"password!");
			password.focus();
			return false;
		}
		if(password.value.length < 6){
			alert("Password length should be minimum 6 characters!");
			password.focus();
			return false;
		}
		return true;
	}
}
//-->
function modiPass(){
	with(document.ckpass){
		var mp = "Please enter your ";
		var myPass = "Password length should be minimum 6 characters!";
		if(password.value==""){
			alert(mp+"Old password!");
			password.focus();
			return false;
		}
		if(password.value.length < 6){
			alert(myPass);
			password.focus();
			return false;
		}
		if(new_pass.value==""){
			alert(mp+"New password!");
			new_pass.focus();
			return false;
		}
		if(new_pass.value.length < 6){
			alert("New "+myPass);
			new_pass.focus();
			return false;
		}	
		if(new_pass1.value==""){
			alert(mp+"new password!");
			new_pass1.focus();
			return false;
		}
		if(new_pass1.value.length < 6){
			alert("New "+myPass);
			new_pass1.focus();
			return false;
		}	
		return true;	
	}
}

function validateRequest(){
	with(document.frmRequest){
		var valReq = "Please enter your ";
		if(name.value.length < 1){
			alert(valReq+"name!");
			name.focus();
			return false;
		}
		if(email.value == "" ){
			alert(valReq+"email address!");
			email.focus();
			return false;
		}
		if(!echeck(email.value)){
			email.focus();
			return false;
		}
		//if(company_name.value.length < 1){
			//alert(anw+"company name!");
			//company_name.focus();
			//return false;
		//}
		/*if(telephone_number.value.length < 1){
			alert(anw+"telephone number!");
			telephone_number.focus();
			return false;
		}*/
		if(city.value.length < 1){
			alert(valReq+"city!");
			city.focus();
			return false;
		}
		if(feedback.value.length < 1){
			alert(valReq+"feedback!");
			feedback.focus();
			return false;
		}
	}
	return true;
}

function chkqck(){
	with(document.quickreg){
		var qr = "Please enter your ";
		if(name.value == ""){
			alert(qr+"First Name");
			name.focus();
			return false;
		}
		if(surname.value == ""){
			alert(qr+"Last Name");
			surname.focus();
			return false;
		}
		if(Date_of_Birth.value == ""){
			alert("Please Select your Date of Birth");
			cal_img.focus();
			return false;
		}
		if(tel.value == "" ){
			alert(qr+"Telephone No.");
			tel.focus();
			return false;
		}
		if(mob.value == ""){
			alert(qr+"Mobile No.");
			mob.focus();
			return false;
		}
		if(address.value == ""){
			alert(qr+"Address");
			address.focus();
			return false;
		}
		if(email.value == ""){
			alert(qr+"Email Address");
			email.focus();
			return false;
		}
		if(!echeck(email.value)){
			email.focus();
			return false;
		}
		if(password1.value == ""){
			alert(qr+"Password");
			password1.focus();
			return false;
		}
		if(password1.value.length < 6 ){
			alert("Password should be six or more letters");
			password1.focus();
			return false;
		}
		if(password2.value == ""){
			alert("Please retype your Password");
			password2.focus();
			return false;
		}
		if(password2.value != password1.value){
			alert("Password and Retype password should be same");
			password2.focus();
			return false;
		}
		/*if(sec_que.value == ""){
			alert("Please select your Security Question");
			sec_que.focus();
			return false;
		}
		if(sec_ans.value == ""){
			alert(qr+"Answer for "+sec_que.value);
			sec_ans.focus();
			return false;
		}*/
		if(expectation.value == ""){
			alert(qr+"Partner Expectation");
			expectation.focus();
			return false;
		}
	return true;
	}
}
/* Report Abuse User */
function abuse_report(){
	with(document.frmreport){
		var abr = "Please provide Abuse User's ";
		if (sender_email.value == ""){
			alert("Please type your Email ID");
			sender_email.focus();
			return false;
		}
		if (!echeck (sender_email.value)){
			sender_email.focus();
			return false;
		}
		if (abuse_id.value == ""){
			alert(abr+"ID");
			abuse_id.focus();
			return false;
		}
		if (abuse_name.value == ""){
			alert(abr+"Name");
			abuse_name.focus();
			return false;
		}
		if (abuse_email.value == ""){
			alert(abr+"Email Address");
			abuse_email.focus();
			return false;
		}
		if (!echeck (abuse_email.value)){
			alert(abr+"valid Email Address");
			abuse_email.focus();
			return false;
		}
		if (abuse_details.value == ""){
			alert("Please write brief details");
			abuse_details.focus();
			return false;
		}
		return true;
	}
}
/* Report Abuse User ends */

/* check for blank input */
function blank_check(){
	with(document.profile){
		var bc = "Please type profile id to search!";
		if(cid.value == "" ){
			alert(bc);
			cid.focus();
			return false;
		}
		return true;
	}
}
/* check for blank input ends */

/* Age Restrictions */
/* Age Restrictions ends */

/* upload photo form */
function chkphoto(){
	with(document.upload_photo){
		var cph = "Please ";
		if(image_1.value ==""){
			alert(cph+"select your photo");
			image_1.focus();
			return false;
		}
	}
}
/* upload photo form ends */
	
function popup(url,width,height,left,top,name){
		var props = "toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,titlebar=no,menubar=no,left="+left+",top="+top+",width="+width+",height="+height;
		w = window.open(url, name, props);
		if (w) {
		w.focus();
		}
}

/* Menu javascript starts here */

var mastertabvar=new Object()
mastertabvar.baseopacity=0
mastertabvar.browserdetect=""

function showsubmenu(masterid, id){
	if (typeof highlighting!="undefined")
	clearInterval(highlighting)
	submenuobject=document.getElementById(id)
	mastertabvar.browserdetect=submenuobject.filters? "ie" : typeof submenuobject.style.MozOpacity=="string"? "mozilla" : ""
	hidesubmenus(mastertabvar[masterid])
	submenuobject.style.display="block"
	instantset(mastertabvar.baseopacity)
	highlighting=setInterval("gradualfade(submenuobject)",50)
}

function hidesubmenus(submenuarray){
	for (var i=0; i<submenuarray.length; i++)
	document.getElementById(submenuarray[i]).style.display="none"
}

function instantset(degree){
	if (mastertabvar.browserdetect=="mozilla")
	submenuobject.style.MozOpacity=degree/100
	else if (mastertabvar.browserdetect=="ie")
	submenuobject.filters.alpha.opacity=degree
}


function gradualfade(cur2){
	if (mastertabvar.browserdetect=="mozilla" && cur2.style.MozOpacity<1)
	cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
	else if (mastertabvar.browserdetect=="ie" && cur2.filters.alpha.opacity<100)
	cur2.filters.alpha.opacity+=10
	else if (typeof highlighting!="undefined") //fading animation over
	clearInterval(highlighting)
}

function initalizetab(tabid){
	mastertabvar[tabid]=new Array()
	var menuitems=document.getElementById(tabid).getElementsByTagName("div")
	for (var i=0; i<menuitems.length; i++){
		if (menuitems[i].getAttribute("rel")){
			menuitems[i].setAttribute("rev", tabid) //associate this submenu with main tab
			mastertabvar[tabid][mastertabvar[tabid].length]=menuitems[i].getAttribute("rel") //store ids of submenus of tab menu
			if (menuitems[i].className=="selected")
			showsubmenu(tabid, menuitems[i].getAttribute("rel"))
			menuitems[i].getElementsByTagName("a")[0].onmouseover=function(){
				showsubmenu(this.parentNode.getAttribute("rev"), this.parentNode.getAttribute("rel"))
			}
		}
	}
}
/* menu javascript ends here */

/* change background color */
function myBG(a, changeTo){
	a.style.backgroundColor = changeTo;
}

/* change border color */
function myBorder(myEle, myValue){
	myEle.style.borderColor = myValue;
}

/* Upper Case */
function first_cap(value) {
	if (value != "") {
    	var firstLetter = value.substring(0, 1).toUpperCase();
    	var otherLetter = value.substring(1, value.length).toLowerCase();
    	value = firstLetter + otherLetter;
  	}
	return value;
}

/* hide div */
function show_me(id){
	document.getElementById(id).style.display = 'block';
}
function hide_me(id){
	document.getElementById(id).style.display = 'none';
}
/* hide div ends */